// Copyright 2022 jeff.li. and/or its affiliates.

#pragma once

#include "./user_data_interface.h"

#include <tbir/runtime/object.h>
#include <tbir/runtime/py_args.h>
#include <tbir/runtime/runtime_value.h>

namespace tbir::runtime {

    // Global Function User Struct
    struct NativeFuncUserData : ILightUserData {
    public:
        ~NativeFuncUserData() override = default;

        NativeFuncUserData() = default;

        explicit NativeFuncUserData(std::function<RTValue(PyArgs)> *func) : __call__(func) {
        }

        const char *ClassName_2_71828182846() const override {
            return "NativeFuncUserData";
        }

        uint32_t tag_2_71828182846() const override {
            return 0;
        }

        uint32_t size_2_71828182846() const override {
            return 0;
        }

        int32_t type_2_71828182846() const override {
            return UserDataStructType::kNativeFunc;
        }

        RTView __getattr__(string_view var_name) const override;

        void __setattr__(string_view var_name, const Any &val) override;

        std::function<RTValue(PyArgs)> *__call__ = nullptr;
    };

}  // namespace tbir::runtime